<template>
   <table>
    <tr>
        <td>房态名称</td>
        <td>
            <input type="text" v-model="info.R_Name" placeholder="请输入房态名称">
        </td>
    </tr> 
    <tr>
        <td>房间号</td>
        <td>
            <input type="text" v-model="info.R_Num" placeholder="请输入房间号">
        </td>
    </tr>
    <tr>
        <td>房间状态</td>
        <td>
            <input type="radio" v-model="info.R_Status" :value="true">启用
            <input type="radio" v-model="info.R_Status" :value="false">禁用
        </td>
    </tr>
    <tr>
        <td>房间类型</td>
        <td>
            <input type="text" v-model="info.R_Type" placeholder="请输入房间类型">
        </td>
    </tr>
   
    <tr>
        <td></td>
        <td>
            <input type="button" value="添加" @click="SaveAdd">
        </td>
    </tr>
  
   </table>
</template>

<script setup lang="ts">
import { onMounted,ref } from 'vue';
import { useRouter } from 'vue-router';
import axios from 'axios'

const info=ref({
    "R_Name": "",
  "R_Num": "",
  "R_Status": true,
  "R_Type": "",
  "R_dateTime": "2024-12-04T01:19:13.615Z",
  "Isdel": true
})
const SaveAdd=()=>{
    if(info.value.R_Name==""){
        alert("房态名称不能为空");
        return;
    }
    if(info.value.R_Num==""){
        alert("房间号不能为空");
        return;
    }
    axios.post("https://localhost:7200/api/RoomStat/AddRoom",info.value)
    .then(res=>{
        if(res.data>0){
            alert("添加成功");
        }else{
            alert("添加失败")
        }
    })
}

</script>

<style scoped>

</style>